/*
 * 文件名：AuthoritiesServiceImp.java
 * 版权：Copyright by www.wootide.com
 * 描述：
 * 修改人：develop
 * 修改时间：2013-6-6
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */
package com.wootide.ets.sys.rightinfo.service.imp;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.dao.DataAccessException;

import com.wootide.ets.common.ETSRuntimeException;
import com.wootide.ets.common.ErrorCodes;
import com.wootide.ets.common.Page;
import com.wootide.ets.common.QueryCondition;
import com.wootide.ets.common.Result;
import com.wootide.ets.log.syslog.RunLog;
import com.wootide.ets.sys.rightinfo.dao.AuthoritiesInfoDao;
import com.wootide.ets.sys.rightinfo.pojo.AuthoritiesInfo;
import com.wootide.ets.sys.rightinfo.service.AuthoritiesInfoService;
import com.wootide.ets.sys.rightinfo.transaction.AuthoritiesInfoTransaction;

public class AuthoritiesInfoServiceImp implements AuthoritiesInfoService
{
    /**
     * 日志记录
     */
    private RunLog runLog;
    
    /**
     * 权限信息事务层实例
     */
    private AuthoritiesInfoTransaction authoritiesInfoTransaction;
    
    /**
     * 权限信息数据访问层实例
     */
    private AuthoritiesInfoDao authoritiesInfoDao;
    
    @SuppressWarnings("rawtypes")
    public Result queryMenus(Integer innerIndex, HttpServletRequest request)
    {
     // 打印方法入口参数
        runLog.debug("innerIndex=" + innerIndex);
        
        // 定义返回结果
        Result result = new Result();
        
        try
        {
            List authoritiesInfos = authoritiesInfoDao.findMenuInfosByAuthorityId(2);
            
            result.setResultCode(ErrorCodes.ERRORCODE_SUCC);
            result.setResultList(authoritiesInfos);
        }
        catch (DataAccessException e)
        {
            runLog.error("Find AuthoritiesInfos Failed!", e);
            // 注册修改前的中文路由对象
            result.setResultCode(ErrorCodes.ERRORCODE_DATABASE);
        }
        catch (ETSRuntimeException e)
        {
            //自定义异常
            runLog.info("Mod AuthoritiesInfos! Input Data:" + innerIndex
                    + " Error Message:" + e.getMessage());
            result.setResultCode(e.getErrorCode());
        }
        catch (Exception e)
        {
            runLog.error("Find AuthoritiesInfos Failed!", e);
            // 注册修改前的中文路由对象
            result.setResultCode(ErrorCodes.ERRORCODE_UNKNOW);
        }
        
        return result;
    }
    
    public Result queryForPages(Page page, QueryCondition queryConditon)
    {
        return null;
    }
    
    public Result addOneAuthorities(AuthoritiesInfo authoritiesInfo,
            HttpServletRequest request)
    {
        return null;
    }
    
    public Result modOneAuthorities(AuthoritiesInfo authoritiesInfo,
            HttpServletRequest request)
    {
        return null;
    }
    
    public Result delAuthoritiess(Integer[] innerIndexs,
            HttpServletRequest request)
    {
        return null;
    }
    
    public Result viewOneAuthorities(Integer innerIndex)
    {
        return null;
    }
    
    public Result viewAllAuthorities()
    {
        Result result = new Result();
        try
        {
//            RoleInfo roleInfo = authoritiesInfoTransaction.viewAllAuthorities();
//            result.setResultCode(ErrorCodes.ERRORCODE_SUCC);
//            result.setResultPojo(roleInfo);
        }
        catch (DataAccessException e)
        {
            runLog.error("Find All Authorities Failed!", e);
            // 注册修改前的中文路由对象
            result.setResultCode(ErrorCodes.ERRORCODE_DATABASE);
        }
        catch (ETSRuntimeException e)
        {
            //自定义异常
            runLog.info("Find All Authorities! Input Data: Error Message:" + e.getMessage());
            result.setResultCode(e.getErrorCode());
        }
        catch (Exception e)
        {
            runLog.error("Find All Authorities Failed!", e);
            // 注册修改前的中文路由对象
            result.setResultCode(ErrorCodes.ERRORCODE_UNKNOW);
        }
        return result;
    }
    
    public Result checkContentWhenAdd(String content)
    {
        return null;
    }

    public void setRunLog(RunLog runLog)
    {
        this.runLog = runLog;
    }

    public void setAuthoritiesInfoTransaction(
            AuthoritiesInfoTransaction authoritiesInfoTransaction)
    {
        this.authoritiesInfoTransaction = authoritiesInfoTransaction;
    }

    public void setAuthoritiesInfoDao(AuthoritiesInfoDao authoritiesInfoDao)
    {
        this.authoritiesInfoDao = authoritiesInfoDao;
    }
}
